<?php 

class Menu extends CWidget{

	protected $user = null;
	protected $currentTournament = null;
	protected $tournaments = null;
	
	public function init(){
		if( !Yii::app()->user->isGuest ){
			/* Get user */
			$this->user = Users::model()->findByPk( Yii::app()->user->id );
			
			/* Get available( for season ) tournaments */
			$this->tournaments = Tournaments::getTournamentsByUserAndSeason( Yii::app()->user->id, Yii::app()->user->currentSeason );
			
			foreach( $this->tournaments as $key => $t ){
				if( $t['byDefault'] == "1" ){
					$this->currentTournament = $t;
					unset( $this->tournaments[$key] );
				}
			}
			
		}
	}

    public function run(){
        $this->render( 'menu' );
    }

}